#include "GameMain.h"

// Inititialize the static pointers to null.
GameMain *GameMain::pInstance = 0;
SDL_GraphicsEngine *GameMain::graphics = 0;

GameMain::~GameMain(void)
{
}
////////////////////////////////////////////////////////////////
//
//Function		:   GameMain
//
//Purpose		:	Contructor
//					Initialize component here
///////////////////////////////////////////////////////////////
GameMain::GameMain(SDL_GraphicsEngine *_graphics)
{
	graphics = _graphics;
}
////////////////////////////////////////////////////////////////
//
//Function		:   GetInstance
//
//Purpose		:	Makes the class the first time it is called
//					and then returns the address of the class
///////////////////////////////////////////////////////////////
GameMain *GameMain::GetInstance(void)
{
	//	Check to see if one hasn't been made yet
	if(pInstance == 0)
		pInstance = new GameMain(graphics);

	//	Return the address of the instance.
	return pInstance;
}
////////////////////////////////////////////////////
//
//Function		:   DeleteInstancce
//
//
//Purpose		:	Delete the instance of the class
////////////////////////////////////////////////////
void GameMain::DeleteInstancce(void)
{

	if (pInstance)
	{
		delete pInstance;
		pInstance = 0;
	}
}
string GameMain::GameInit()
{
	graphics->init("Street Fighter Story");

	logo = graphics->Load("logo.bmp");
	return "Init Succeeded";
}
string GameMain::GameShutdown()
{
	graphics->clean_up();
	return "Shutdown Succeeded";
}
void GameMain::Run( void )
{
	//Quit flag
	bool quit = false;
	//While the user hasn't quit
	while( quit == false )
	{
	    //While there's events to handle
	    while( SDL_PollEvent( &event ) )
	    {
	        //If the user has Xed out the window
	        if( event.type == SDL_QUIT )
	        {
	            //Quit the program
	            quit = true;
	        }
	    }

		//Draw the logo
		graphics->Draw(logo, ( graphics->SCREEN_WIDTH - logo->w ) / 2, ( graphics->SCREEN_HEIGHT / 2 - logo->h ) / 2 );


		graphics->Update();
	}
}